package sz.com.postoffice.jxyzwgcase.service.impl;

import javax.annotation.Resource;

import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;
import sz.com.postoffice.jxyzwgcase.core.TableDataInfo;
import sz.com.postoffice.jxyzwgcase.dao.BaseDao;
import sz.com.postoffice.jxyzwgcase.dao.master.EmployeeDao;
import sz.com.postoffice.jxyzwgcase.pojo.Employee;
import sz.com.postoffice.jxyzwgcase.pojo.Vacation;
import sz.com.postoffice.jxyzwgcase.service.EmployeeService;

import java.util.List;


/**
 * @ClassName EmployeeServiceImpl
 * @Deacription 员工逻辑处理层
 * @Author jmx
 * @Date 2020/11/20 18:00
 * @Version 1.0
 **/
@Service
@Slf4j
public class EmployeeServiceImpl extends BaseServiceImpl<Employee> implements EmployeeService {

    @Resource
    private EmployeeDao employeeDao;
    @Override
    protected BaseDao<Employee> getMapper() {
        return this.employeeDao;
    }

    @Override
    public List<Vacation> findVacationByEntity(Vacation vacation) {
        return employeeDao.findVacationByEntity(vacation);
    }

    @Override
    public List<Vacation> findVacationByPeriod(Vacation vacation) {
        return employeeDao.findVacationByPeriod(vacation);
    }

    @Override
    public boolean deleteVacationById(int id) {
        try {
            employeeDao.deleteVacationById(id);
        } catch (Exception e) {
            log.error("delete vacation error,msg is: {}", e.getMessage());
            return false;
        }
        return true;
    }

    @Override
    public Vacation findVacationById(int id) {
        return employeeDao.findVacationById(id);
    }

    @Override
    public boolean insertVacation(Vacation vacation) {
        try {
            employeeDao.insertVacation(vacation);
        } catch (Exception e) {
            log.error("insert vacation error,msg is: {}", e.getMessage());
            return false;
        }
        return true;
    }

    @Override
    public boolean updateVacation(Vacation vacation) {
        try {
            employeeDao.updateVacation(vacation);
        } catch (Exception e) {
            log.error("update vacation error,msg is: {}", e.getMessage());
            return false;
        }
        return true;
    }
}
